<template>
    <div class="box">
        <!-- 头部标题 -->
        <div class="head">
            <div class="cell">
            </div>
            <h1 style="font-weight: normal;">企业信息</h1>
        </div>
        <!-- 表单 -->
        <!-- 企业名称、贷款金额、年收入、经营范围、经营地址、法人姓名、联系电话、经办机构、经办人员、是否在我行开立基本账户是否为选择项 -->
        <div class="table">
            <div class="form" :style="{ height: formHeight.CORP_NAME }">
                <van-cell-group>
                    <van-field label="企业名称" v-model="CORP_NAME" error-message="请输入企业名称" @blur="corpInput" placeholder="请输入企业名称" />
                </van-cell-group>
            </div>
            <div class="form" :style="{ height: formHeight.CERT_NO }">
                <van-cell-group>
                    <van-field label="统一社会信用代码" v-model="CERT_NO" error-message="请输入统一社会信用代码" disabled placeholder="请输入统一社会信用代码" />
                </van-cell-group>
            </div>
            
            <div class="form">
                <van-cell-group>
                    <van-field
                    readonly
                    v-model="LOAN_TERM"
                    label="申请期限"
                    placeholder="请选择申请期限"
                    @click="termPicker = true"
                    />
                    <van-popup v-model="termPicker" position="bottom">
                    <van-picker
                        show-toolbar
                        :columns="LOAN_TERMList"
                        @confirm="termConfirm"
                        @cancel="termPicker = false"
                    />
                    </van-popup>
                </van-cell-group>
            </div>
            <div class="form" :style="{ height: formHeight.APPLY_AMOUNT }">
                <van-cell-group>
                    <van-field label="申请金额(万元)" type="number" v-model="APPLY_AMOUNT"  error-message="请输入申请金额(万元)" @blur="amountInput" placeholder="请输入申请金额(万元)" />
                </van-cell-group>
            </div>
            <div class="form" :style="{ height: formHeight.LEGAL_PERSON_NAME }">
                <van-cell-group>
                    <van-field label="法人姓名" v-model="LEGAL_PERSON_NAME"  error-message="请输入法人姓名" @blur="nameInput" placeholder="法人姓名" />
                </van-cell-group>
            </div>
            <div class="form" :style="{ height: formHeight.NUMBER }">
                <van-cell-group>
                    <van-field label="联系电话" type="number" v-model="NUMBER"  error-message="请输入联系电话" @blur="numberInput" placeholder="联系电话" />
                </van-cell-group>
            </div>
            <div class="form" :style="{ height: formHeight.CORP_BUSINESS_SCOPE }">
                <van-cell-group>
                    <van-field label="经营范围" v-model="CORP_BUSINESS_SCOPE" disabled  error-message="请输入经营范围" @blur="scopeInput" placeholder="经营范围" />
                </van-cell-group>
            </div>
            <div class="form" :style="{ height: formHeight.SCOPE_ID }">
                <van-cell-group>
                    <van-field label="经营地址" v-model="SCOPE_ID"  error-message="请输入经营地址" disabled @blur="scopeidInput" placeholder="经营地址" />
                </van-cell-group>
            </div>
            <div class="form">
                <van-cell-group>
                    <van-field
                    readonly
                    v-model="selectedfrOrg"
                    label="法人机构"
                    placeholder="请选择法人机构"
                    @click="FrPicker = true"
                    />
                    <van-popup v-model="FrPicker" position="bottom">
                    <van-picker
                        show-toolbar
                        :columns="FRList"
                        @confirm="FrConfirm"
                        @cancel="FrPicker = false"
                    />
                    </van-popup>
                </van-cell-group>
            </div>
            <div class="form">
                <van-cell-group>
                    <van-field
                    readonly
                    v-model="selectedOrg"
                    label="经办机构"
                    placeholder="请选择经办机构"
                    @click="showPicker = true"
                    />
                    <van-popup v-model="showPicker" position="bottom">
                    <van-picker
                        show-toolbar
                        :columns="orgList"
                        @confirm="handleConfirm"
                        @cancel="showPicker = false"
                    />
                    </van-popup>
                </van-cell-group>
            </div>
            <div class="form">
                <van-cell-group>
                    <van-field
                    readonly
                    v-model="selectedAccount"
                    label="经办人员"
                    placeholder="请选择经办人员"
                    @click="accountPicker = true"
                    />
                    <van-popup v-model="accountPicker" position="bottom">
                    <van-picker
                        show-toolbar
                        :columns="accountList"
                        @confirm="accountConfirm"
                        @cancel="accountPicker = false"
                    />
                    </van-popup>
                </van-cell-group>
            </div>
        </div>
        <!-- 底部提交按钮 -->
        <div class="submit" @click="submit">
            提交
        </div>
    </div>
</template>
<script>

export default {
    name:'productIndex',
    data() {
        return {
            accountList:[],
            accountPicker:false,
            selectedAccount:'',
            selectedfrOrg:'',
            FRList:[],
            FrOrg:'',
            LOAN_TERMList:[
                '3','4','5','6','7','8','9','10','11','12'
            ],
            FrPicker:false,
            termPicker:false,
            showPicker:false,
            selectedOrg:'',
            orgList: [
            ],
            formHeight:{
                CORP_NAME:'4rem',
                LOAN_TERM:'4rem',
                LEGAL_PERSON_NAME:'4rem',
                NUMBER:'4rem',
                CORP_BUSINESS_SCOPE:'4rem',
                SCOPE_ID:'4rem',
                APPLY_AMOUNT:'4rem',
                CERT_NO:'4rem'
                
            },
            APPLY_AMOUNT:'',
            CORP_NAME:'',
            LOAN_TERM:'',
            LEGAL_PERSON_NAME:'',
            NUMBER:'',
            CORP_BUSINESS_SCOPE:'',
            SCOPE_ID:'',
            REGI_ORG:'',
            LOAN_MARKETING_NAME:'',
            CERT_TYPE:'',//营业执照类型
            CERT_NO:'',//统一社会信用代码
            TYPE:'',//工商-企业类型
            BUSINESS_CITY:'',//经营城市
            BUSINESS_CITY_CODE:'',//城市编码
            BUSINESS_DISTRICT:'',//经营区域
            BUSINESS_DISTRICT_CODE:'',//区域代码
            CERTIFICATE_VALIDITY:'',//组织机构有效期限
            BUILD_DATE:'',//成立日期
            CORP_CUST_NO:'',//信贷客户号
            CORP_HXKHBH:'',//核心客户号
            CORP_ZZJGDM:'',//组织机构代码
            REGI_CURR:'', // 注册资本币种
			ACT_CURR:'',//实收资本币种
            REGI_CAPITAL:'', // 注册资本
			ACT_CAPITAL:'', // 实收资本
            TIME_MARK:'',//影像时间
            BUSINESS_NUM:'',//合同号
            productName:'',//产品码值
            accountphone:'',
            userid:'',
            usercode:'',
            openid:'',
        }
    },
    mounted() {
        console.log(this.__ctx);
        console.log(process.env.NODE_ENV );
        
    },
    created() {
        if(this.$route.query.id == '1') {//id=1 助企流水贷
            this.productName = '030113'
        }else {//助企周转贷
            this.productName = '030114'

        }
        this.userid = this.$route.query.userid
        this.usercode = this.$route.query.usercode
        this.openid = this.$route.query.openid
    },
    methods:{
        termConfirm(item) {
            this.LOAN_TERM = item
            this.termPicker = false
        },
        accountConfirm(item) {
            // // 使用Fisher-Yates算法打乱数组
            console.log(this.selectedAccount);
            this.selectedAccount = item.text; // 更新字段显示的是选中项的名称
            this.LOAN_MARKETING_NAME = item.value; // 更新字段显示的是选中项的名称
            this.accountphone = item.phone
            this.accountPicker = false;
        },
        FrConfirm(item) {
            console.log(item)
            this.selectedfrOrg = item.text; // 更新字段显示的是选中项的名称
            this.FrOrg = item.value; // 更新字段显示的是选中项的名称
            this.FrPicker = false;
            this.getChengeOrg(this.FrOrg)
        },
        //获取经办机构
        getChengeOrg(value) {
            var value = value
            var that =this
            that.orgList = []
            that.selectedOrg = ''
            that.REGI_ORG = ''
            var data = {
                RgstUsrId:that.SCOPE_ID,//注册地址
                UsrNm: that.BUSINESS_NUM,//合同号
            }
            that.$api.GetOrgSearch(data).then(res => {
                console.log(res,211);
                if(res.Head.RspSt && res.Head.RspSt == '200') {
                    for(var i = 0 ; i <res.Data.LegInfArr.length; i++) {
                        if(value == res.Data.LegInfArr[i].LegCd) {
                            for(var j = 0 ; j <res.Data.LegInfArr[i].BrInfArr.length; j++) {
                                that.orgList.push({
                                    text : res.Data.LegInfArr[i].BrInfArr[j].BrNm,
                                    value: res.Data.LegInfArr[i].BrInfArr[j].BrCd
                                })
                            }
                        }
                    }
                    console.log(that.orgList);
                }else {
                    that.$toast({
                        duration:3000,
                        icon: 'warning',
                        message: res.Head.RspInf
                    });
                }
            })
        },
        
        
        handleConfirm(item) {
            
            this.selectedOrg = item.text; // 更新字段显示的是选中项的名称
            this.REGI_ORG = item.value; // 更新字段显示的是选中项的名称
            console.log(this.REGI_ORG,this.selectedOrg);
            this.GetOrgList()
            this.showPicker = false;
        },
        GetOrgList() {
            var that = this 
            that.accountList = []
            that.selectedAccount = ''
            that.LOAN_MARKETING_NAME = ''
            var data = {
                "AgnOrg":that.REGI_ORG,
                'PactNo': that.BUSINESS_NUM,
            }
            that.$api.GetAccountList(data).then(res => {
                console.log(res);
                if(res.Head.RspSt && res.Head.RspSt == '200') {
                    for(var i = 0 ; i <res.Data.UsrInfArr.length; i++) {
                        that.accountList.push({
                            text : res.Data.UsrInfArr[i].UsrNm,
                            value: res.Data.UsrInfArr[i].UsrId,
                            phone: res.Data.UsrInfArr[i].MblTel
                        })
                    }
                    let array = [...this.accountList];
                    let currentIndex = array.length;
                    let temporaryValue, randomIndex;
                    while (0 !== currentIndex) {
                        randomIndex = Math.floor(Math.random() * currentIndex);
                        currentIndex -= 1;
                        temporaryValue = array[currentIndex];
                        array[currentIndex] = array[randomIndex];
                        array[randomIndex] = temporaryValue;
                    }
                    this.accountList = array;
                }else {
                    this.$toast({
                        duration:3000,
                        icon: 'warning',
                        message: res.Head.RspInf,
                    });
                }
            })
        },
        submit() {
            var that = this
            if(!this.CORP_NAME) {
                this.$toast({
                    duration:3000,
                    icon: 'clear',
                    message: '请输入企业名称！',
                });
                return
            }
            if(!this.LOAN_TERM) {
                this.$toast({
                    duration:3000,
                    icon: 'clear',
                    message: '请选择申请期限！',
                });
                return
            }
            if(!this.APPLY_AMOUNT) {
                this.$toast({
                    duration:3000,
                    icon: 'clear',
                    message: '请输入申请金额(万元)！',
                });
                return
            }
            if(!this.LEGAL_PERSON_NAME) {
                this.$toast({
                    duration:3000,
                    icon: 'clear',
                    message: '请输入法人姓名！',
                });
                return
            }
            if(!this.NUMBER) {
                this.$toast({
                    duration:3000,
                    icon: 'clear',
                    message: '请输入联系电话！',
                });
                return
            }
            if(!this.CORP_BUSINESS_SCOPE) {
                this.$toast({
                    duration:3000,
                    icon: 'clear',
                    message: '请输入经营范围！',
                });
                return
            }
            if(!this.SCOPE_ID) {
                this.$toast({
                    duration:3000,
                    icon: 'clear',
                    message: '请输入经营地址！',
                });
                return
            }
            if(!this.selectedfrOrg) {
                this.$toast({
                    duration:3000,
                    icon: 'clear',
                    message: '请选择法人机构！',
                });
                return
            }
            if(!this.selectedOrg) {
                this.$toast({
                    duration:3000,
                    icon: 'clear',
                    message: '请选择经办机构！',
                });
                return
            }
            if(!this.selectedAccount) {
                this.$toast({
                    duration:3000,
                    icon: 'clear',
                    message: '请选择经办人员！',
                });
                return
            }
            this.$toast.loading({
                duration: 0,
                message: '派单发起中...',
                forbidClick: true,
            });
            that.getplms130()
          
        },
        getEnterName() {//获取合同号
           
            var that = this
            var data = {
            }
            that.$api.GetBussines(data).then(res => {
                
                if(res.Head.RspSt && res.Head.RspSt == '200') {
                    that.BUSINESS_NUM = res.Data.SpecificData
			        that.BusinessNumber()

                }else {
                    that.$toast({
                        duration:3000,
                        icon: 'warning',
                        message: res.Head.RspInf
                    });
                }
            })
            
        },
        BusinessNumber() {//工商查询
            var that = this 
            var orgcode = ''
            if(this.usercode) {
                orgcode = this.usercode
            }else {
                orgcode = '1018'
            }

            var data = {
                "EntpNm":that.CORP_NAME,
                // "EntpNm":'沈阳富仕名嘉商贸有限公司',
                "AgnOrg": orgcode,
                // "AgnOrg":this.usercode,
                "PactNo":that.BUSINESS_NUM
                // "PactNo":'123456'
            }
            that.$api.GetEnterName(data).then(res => {
                console.log(111,res);
                if(res.Head.RspSt && res.Head.RspSt == '200') {
						that.SCOPE_ID = res.Data.CompanyAdr //经营地址（同注册地址）
						that.CERT_TYPE = "610005" // 固定赋值为：610005-营业执照
						that.CERT_NO = res.Data.CreditCd // 统一社会信用代码
						that.CORP_NAME = res.Data.EntpNm // 企业名称
						that.TYPE=res.Data.EntpTy // 工商-企业类型
						that.BUSINESS_CITY=res.Data.BsnCity // 经营城市
						that.BUSINESS_CITY_CODE=res.Data.BsnCityCd // 经营城市编码
						that.BUSINESS_DISTRICT=res.Data.CompanyAdr // 经营区域
						that.BUSINESS_DISTRICT_CODE=res.Data.BsnDivsCd // 经营区域编码
						if (res.Data.BrCd) {
							that.CORP_ZZJGDM=res.Data.BrCd.substring(0, res.Data.BrCd.length-1) + '-' + res.Data.BrCd.substring(res.Data.BrCd.length-1, res.Data.BrCd.length) //组织机构代码
						}
						var OPTO = res.Data.VldTerm
						if (OPTO == "长期") {
							OPTO = "9999-12-31"
						}
						that.CERTIFICATE_VALIDITY=OPTO      //组织机构有效期限
						that.CORP_BUSINESS_SCOPE = res.Data.BsnScop  //经营范围
						that.LEGAL_PERSON_NAME = res.Data.LegNm //法人姓名
                        // that.NUMBER = res.Data.Tel //电话
                        
						that.REGI_ORG = res.Data.RgstInst // 登记机关
						var REGCAP = res.Data.RgstCap ? res.Data.RgstCap * 10000: 0
						var RECCAP = res.Data.PdupCap ? res.Data.PdupCap * 10000: 0
						that.REGI_CAPITAL = REGCAP // 注册资本
						that.ACT_CAPITAL = RECCAP // 实收资本
						that.BUILD_DATE = res.Data.RgstDt // 成立日期
                        that.getplms128()
				} else{
                    this.$toast({
                        duration:3000,
                        icon: 'warning',
                        message: "请检查企业名称是否输入正确，并重试！"
                    });
                }
            })
            
        },
        // 
        getplms128() { //法人机构信息查询(非异地)
            var that = this
            that.FRList = []
            var data = {
                RgstUsrId:that.SCOPE_ID,//注册地址
                UsrNm: that.BUSINESS_NUM,//合同号
            }
            that.$api.GetOrgSearch(data).then(res => {
                console.log(res,111111)
                if(res.Head.RspSt && res.Head.RspSt == '200') {
                    for(var i = 0 ; i <res.Data.LegInfArr.length; i++) {
                        that.FRList.push({
                            text : res.Data.LegInfArr[i].LegNm,
                            value: res.Data.LegInfArr[i].LegCd
                        })
                    }
                }else {
                    that.$toast({
                        duration:3000,
                        icon: 'warning',
                        message: res.Head.RspInf
                    });
                }
            })
        },
        
        getplms130() {
            // 辽宁艾斯兰德科技有限公司
            var data = {
                "IdentTp":"6100AA",//证件类型
                "EntpNm":this.CORP_NAME,//企业名称
                "Flag":"1", //是否进行订单分发字段
                "CstMgrNo":this.LOAN_MARKETING_NAME, //营销人
                "IdentNo":this.CERT_NO, //统一社会信用代码
                "BsnAdr":this.SCOPE_ID,//注册地址
                "AgnOrg" :this.REGI_ORG//经办机构
            }
            // var data = {
            //     "IdentCustName":'沈阳富仕名嘉商贸有限公司',
            //     'IdentType':'6100AA',
            //     'IdentNo':'91210105MABNCF6Q56',
            //     'isAllocation':'1',
            //     'RegAddress':'辽宁省沈阳市和平区',
            //     'orgCode':'1096',
            //     'managerId':'112221',

            // }
			var that = this;
            that.$api.GetStockCstDtMng(data).then(res => {
            // that.baseService.post(this.__ctx + '/api/mini/dataGovernance', data).then(res => {
                console.log(1,res)
                if(res.Head.RspSt && res.Head.RspSt == '200') {
                    var managerId = res.Data.CstMgrNo
                    var corporCd = res.Data.LegCd
                    var orgCode = res.Data.AgnOrg
                    var phone = res.Data.CstMgrTel
                    var AcctOpnFlg = res.Data.AcmFlg  //新老客户标识
                    that.CORP_CUST_NO = res.Data.CoopCstNo  //信贷客户号
                    that.CORP_HXKHBH = res.Data.CoreCstNo  //核心客户号
                    that.TIME_MARK = res.Data.Tmstmp  
              
                    that.startInstance(managerId,corporCd,orgCode,AcctOpnFlg)
                } else if(res.Head.RspSt == '203') {
                    this.$toast({
                        duration:3000,
                        icon: 'warning',
                        message: '该客户证件号码与存量客户信息中的证件号码不一致!',
                    });
                } else if(res.Head.RspSt == '204') {
                    this.$toast({
                        duration:3000,
                        icon: 'warning',
                        message: '当前用户存在多条客户信息请进行数据治理!',
                    });
                } else if(res.Head.RspSt == '205') {
                    this.$toast({
                        duration:3000,
                        icon: 'warning',
                        message: '该客户名称与存量客户信息中的客户名称不一致!',
                    });
                } else if(res.Head.RspSt == '206') {
                    this.$toast({
                        duration:3000,
                        icon: 'warning',
                        message: '该客户认定为新客户但是信贷系统中存在客户信息!',
                    });
                }else {
                    this.$toast({
                        duration:3000,
                        icon: 'warning',
                        message: '系统开小差了!',
                    });
                }
            })
        },
        // 埋点
        getBurialPoint() {
            var that = this
            var key = ''
            var serviceType = ''
            if(that.productName == '030113') { //助企流水贷
                key = '助企流水贷'
                serviceType = '8206'
            }else {//助企周转贷
                key = '助企周转贷'
                serviceType = '8306'

            }
            var data = {
                CstToken:that.openid,//微信OPENID
                BurTp:'2',//	埋点类型
                BsnTp:serviceType,//	业务类型
                BrNo:'',  //	网点机构
                LegCd:that.usercode,    //法人机构
                CstMgrNo:that.userid,   //	客户经理ID
                PdNo:that.BUSINESS_NUM,   //	产品ID
                PdTp:that.LOAN_TERM, //	产品类型
                PdNm:key, //	产品名称
                PdGrp:that.APPLY_AMOUNT,//	产品组
                ChnlSrc:'',         //	来源渠道
                
            }
            console.log(data);
            that.$api.UpBurialPointData(data).then(res => {
                console.log(res);
            })

        },
        startInstance(managerId,corporCd,orgCode,AcctOpnFlg) {
            var that =this
            var managerId =managerId
            var corporCd =corporCd
            var orgCode =orgCode
            var AcctOpnFlg = AcctOpnFlg
            var data = {
                "CmpnObj": "1",//申贷对象
                "BsnTp": "030100",//业务种类
                "GntTp": "1", //发放类型
                "PdNm": that.productName,  //产品名称
                "VouTp": "1",//担保方式
                "EntpNm": that.CORP_NAME, //企业名称
                "IdentTp": "610005", //证件类型
                "IdentNo": that.CERT_NO, //营业执照号
                "RgstInst": that.REGI_ORG,//登记机关
                "CoreCstNo": that.CORP_HXKHBH, //核心客户号
                "CoopCstNo": that.CORP_CUST_NO,  //信贷客户号
                "BsnCity": that.BUSINESS_CITY,  //经营地址市
                "BsnCityCd": that.BUSINESS_CITY_CODE,//经营地址市编码
                "BsnDivsNm": that.BUSINESS_DISTRICT,//经营地址区
                "BsnDivsCd":that.BUSINESS_DISTRICT_CODE,  //经营区域编码
                "BrCd": that.CORP_ZZJGDM,  //组织机构代码
                "IdentTerm": that.CERTIFICATE_VALIDITY,//组织机构有效期限
                "RgstAdr": that.SCOPE_ID, //注册地址
                "CompanyAdr": that.SCOPE_ID,//经营地址 
                "RgstDt":  that.BUILD_DATE,//成立日期
                "BsnScop": that.CORP_BUSINESS_SCOPE,//经营范围
                "Nm": that.LEGAL_PERSON_NAME,  //法人名称
                // "Gnd"://性别
                //Race://民族
                // BrthDt://出生日期
                // CertAdr:''//户籍地址
                // LegIdentNo:''//法人证件号码
                // SignOrg:''//签发机关
                // VldTerm:''//有效期限
                // LegIdentTp:''//法人证件类型
                // Province:''//居住地省
                // ProvinceCd:''//省份码值
                // City:''//居住地市
                // CityCd:'',//城市码值
                // DivsNm://居住地区
                // DivsCd:'',//行政区码值
                // Adr:'',//居住地址
                "MblTel": that.NUMBER,//手机号
                "AplAmt":that.APPLY_AMOUNT,//申请金额
                "AplTerm":that.LOAN_TERM,//申请期限
                // "LoanPps":'',//贷款用途
                // "AplyDate":'',//申请日期
                "PactNo":that.BUSINESS_NUM,//合同号
                "BrNo": that.REGI_ORG, //机构码值
                "TlrNo": that.LOAN_MARKETING_NAME, //柜员号
                "Tmstmp": that.TIME_MARK,//影像时间
                // "DECISION_TYPE":""//决策类型
                // "SUGG_TERM":'',//建议期限
                // "SUGG_AMT":'',//建议额度
                // "SUGG_JZDCJB":'',//信用等级（建议调查级别）
                // "QUANT_SCORE":'',//建议利率
                "BrTp": that.TYPE,   //企业工商类型
                "AcmFlg":AcctOpnFlg,//新老客户标识
                "CreditCd": that.CORP_ZZJGDM,//统一信用代码
                "LegNm": that.LEGAL_PERSON_NAME,  //法人名称
                "CompanyRgstAdr":  that.SCOPE_ID,//企业注册地址
                "RgstCap": that.REGI_CAPITAL,//注册资本
                "PdupCap": that.ACT_CAPITA,//实收资本
                "LegCd": that.FrOrg,//法人机构
                "TlrNm":that.selectedAccount,//柜员名称
                "CstMgrNo":that.userid, //营销人工号
                "CstMgrNm":that.usercode ,//营销机构
            }
            console.log(data);
            console.log(that.REGI_ORG);
            console.log(that.LOAN_MARKETING_NAME);
            that.$api.GetDispatchFlowStart(data).then(res => {
                console.log(res)
                if(res.Head.RspSt && res.Head.RspSt == '200') {
                    that.orgsms(corporCd,that.NUMBER)
                    that.sms(corporCd,that.NUMBER)
                    that.getBurialPoint()
                }else {
                    this.$toast({
                        duration:3000,
                        icon: 'warning',
                        message: res.Head.RspInf
                    });
                }
               
            })
        },
        //发送短信模板
        sms(corporCd,phone) { //经办人短信
            var that = this
            var key = ''
            if(that.productName == '030113') { //助企流水贷
                key = '助企流水贷'
            }else {//助企周转贷
                key = '助企周转贷'
            }
            var data = {
                "MblTel":that.accountphone, //贷款和经办人
                "SmyDesc1":that.selectedAccount,//经办人名称
                "SmyDesc2":that.LEGAL_PERSON_NAME,//客户名称
                "SmyDesc3":key,
                "TplNo":"1001020179",
                "BsnTp":"06",
                "LegCd":that.FrOrg,
                // "LegCd":'1147',
                "PactNo":that.BUSINESS_NUM
            }
            
            console.log(data);

            that.$api.GetMsgSendChk(data).then(res => {
                console.log(2,res)
                if(res.Head.RspSt && res.Head.RspSt == '200') {
                    setTimeout(()=>{
                        window.wx.miniProgram.navigateBack({});
                    },3000)
                }else {
                    this.$toast({
                        duration:3000,
                        icon: 'warning',
                        message: res.Head.RspInf
                    });
                    setTimeout(()=>{
                        window.wx.miniProgram.navigateBack({});
                    },3000)
                }
                
            })
        },
         //发送短信模板
        orgsms(corporCd,phone) {//客户短信
            var that = this
            var key = ''
            if(that.productName == '030113') { //助企流水贷
                key = '助企流水贷'
            }else {//助企周转贷
                key = '助企周转贷'
            }
            var data = {
                "SmyDesc1":that.LEGAL_PERSON_NAME,//客户名称
                "SmyDesc2":key,
                "SmyDesc3":that.selectedAccount,//经办人名称
                "SmyDesc4":that.accountphone,//经办人电话
                "MblTel":that.NUMBER, //贷款和经办人
                "TplNo":"1001020178",
                "BsnTp":"06",
                "LegCd":that.FrOrg,
                // "LegCd":'1147',
                "PactNo":that.BUSINESS_NUM
            }
            console.log(data);
            that.$api.GetMsgSendChk(data).then(res => {
                console.log(1,res)
                if(res.Head.RspSt && res.Head.RspSt == '200') {
                    this.$toast.clear();
                    this.$toast({
                        duration:3000,
                        icon: 'checked',
                        message: '尊敬的'+ that.LEGAL_PERSON_NAME + '客户您好，我行已收到您关于'+key+'的业务申请。您的客户经理：'+that.selectedAccount+'，联系电话：'+that.accountphone+'。',
                    });
                    setTimeout(()=>{
                        window.wx.miniProgram.navigateBack({});
                    },3000)
                }else {
                    setTimeout(()=>{
                        window.wx.miniProgram.navigateBack({});
                    },3000)
                    // this.$toast({
                    //     duration:3000,
                    //     icon: 'warning',
                    //     message: res.Head.RspInf
                    // });
                }
            })
        },
        amountInput() {
            if(!this.APPLY_AMOUNT) {
                this.formHeight.APPLY_AMOUNT = '6rem'
            }else {
                this.formHeight.APPLY_AMOUNT = '4rem'
            }
            var number = this.APPLY_AMOUNT
            number = Number(number)
            if(number<0 || number==0 || number>300 ) {
                this.$toast({
                    duration:3000,
                    icon: 'warning',
                    message: '申请额度范围0-300万元,请输入正确金额!',
                });
                this.APPLY_AMOUNT = ''
            } else {
                number = Math.round(number *100) /100
                this.APPLY_AMOUNT = number
                console.log(number);
            }

        },
        corpInput() {
            if(!this.CORP_NAME) {
                this.formHeight.CORP_NAME = '6rem'
            }else {
                this.formHeight.CORP_NAME = '4rem'
            }
            this.getintransit()
        },
        // 
        getintransit() {
            var that = this 
            var data = {
                'Nm': that.CORP_NAME
            }
            that.$api.GetProInTransChk(data).then(res => {
                console.log(res,3);
                if(res.Head.RspSt && res.Head.RspSt == '200') {
                    this.getEnterName()
                }else {
                    this.$toast({
                        duration:3000,
                        icon: 'warning',
                        message: res.Head.RspInf
                    });
                    return
                }
            })

        },
        nameInput() {
            if(!this.LEGAL_PERSON_NAME) {
                this.formHeight.LEGAL_PERSON_NAME = '6rem'
            }else {
                this.formHeight.LEGAL_PERSON_NAME = '4rem'
            }
        },
        numberInput() {
            if(!this.NUMBER) {
                this.formHeight.NUMBER = '6rem'
            }else {
                this.formHeight.NUMBER = '4rem'
            }
            // 这里使用的是简单的中国大陆手机号码正则，根据需要可以进行扩展或修改
            const regex = /^1[3-9]\d{9}$/;
            if(regex.test(this.NUMBER) == false) {
                this.$toast({
                    duration:3000,
                    icon: 'warning',
                    message: '请输入正确的手机号码!',
                });
                this.NUMBER = ''
            }
        },
        scopeInput() {
            if(!this.CORP_BUSINESS_SCOPE) {
                this.formHeight.CORP_BUSINESS_SCOPE = '6rem'
            }else {
                this.formHeight.CORP_BUSINESS_SCOPE = '4rem'
            }
        },
        scopeidInput() {
            if(!this.SCOPE_ID) {
                this.formHeight.SCOPE_ID = '6rem'
            }else {
                this.formHeight.SCOPE_ID = '4rem'
            }
        },
        // 拍照/上传文件识别营业执照
        // corpupload() {
        //     // 触发文件输入
        //     this.$refs.fileInput.click();
        // },
         // 处理文件选择
        handleFileChange(event) {
            this.imageurl = ''
            const file = event.target.files[0];
            if (file) {
                // 这里可以添加代码来处理文件，例如上传到服务器
                const reader = new FileReader(); // 创建 FileReader 对象
                reader.onload = (loadEvent) => {
                    const base64String = loadEvent.target.result; // 转换完成的Base64字符串
                    this.imageurl = base64String
                };
                reader.readAsDataURL(file); // 将文件读取为DataURL（Base64）
            }
        }
    }

}
</script>

<style scoped lang="less">
/deep/ .van-picker-column__item {
    .van-ellipsis {
        width: 80%;
        line-height: 1.5;
        white-space: pre-wrap;
        overflow-wrap: break-word;
        text-align: center;
    }
}
/deep/.van-field--disabled .van-field__label {
    color:#646566 !important;
}
/deep/ .van-field__label {
    width: 10rem !important;
}
/deep/.van-icon-arrow:before {
   margin-top: 0.8rem !important;
}

.box {
    width: 100%;
    height: 100%;
}
.head {
    position: relative;
    width: 100%;
    height: 4.4rem;
    line-height: 4.4rem;
    background-color: #fff;
    text-align: center;
    font-size: 0.8rem;
    border-bottom: 0.1rem solid #ccc;
}
.cell {
    width: 4rem;
    height: 4.4rem;
    line-height: 4.4rem;
    position: absolute;
    left: 1rem;
    font-size: 1.6rem;
}
.title {
    width: 90%;
    margin: 0 auto;
    font-size: 1.2rem;
    font-weight: 700;
    height: 7.5rem;
    line-height: 7.5rem;
}

.table {
    width: 90%;
    margin: 3rem auto 0;
    background-color: #fff;
    border-radius: 0.4rem;
    box-shadow:0 0 0.7rem #ccc;
    padding:0.5rem 0
}
.form {
    width: 90%;
    height: 4rem;
    line-height: 4rem;
    margin: 0.5rem auto;
}
.van-hairline--top-bottom::after, .van-hairline-unset--top-bottom::after {
    border-top: 0;
}
.van-cell-group {
    background-color: transparent;
    height: 100%;
    line-height: 4rem;

}
.van-cell {
    background-color: transparent;
    height: 100%;
    line-height: 4rem;
    padding: 0;
    font-size: 1.2rem;

}
.submit {
    width: 90%;
    height: 4rem;
    line-height: 4rem;
    background-color: #fa541c;
    color: #fff;
    text-align: center;
    margin: 3rem auto 0;
    font-size: 1.4rem;
    border-radius: 0.5rem;
}
/deep/ .van-field__error-message {
    font-size: 1.5rem;
    height: 2rem !important;
    line-height: 2rem !important;
}

</style>